<?php
/**
 * Created by PhpStorm.
 * User: shkj
 * Date: 2020/8/29
 * Time: 23:07
 */

namespace app\api\controller\v1;


use app\api\service\UserToken;
use app\api\validate\TokenGet;
use think\facade\Request;
use app\api\service\Token as TokenService;
class Token extends Base
{
    public function getToken()
    {
        (new TokenGet())->goCheck();
        $code = Request::param('code');
        $datas = Request::param();
        $data = json_decode($datas['rawData'],true);


        $res = [
                'nick_name'=>$data['nickName'],
                'avatar_url'=>$data['avatarUrl'],
                'gender'=>$data['gender'],
                'country'=>$data['country'],
                'city'=>$data['city'],
                'province'=>$data['province'],
                'create_time'=>time(),
                'update_time'=>time(),

              ];

        $ut = new UserToken($code);
        $token = $ut->get($res);
        return_json(200,'成功',$token);
        // return [
        //     'token'=>$token
        // ];

    }

       //校验token是否有效
    public function verify($uid='',$token=''){
           $data = Request::post();
           $uid = $data[0];
           $token = Request()->header('Token');
           $status = $this->verifyToken($uid,$token);
           return $status;
    }
    


}